﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
namespace TDBaseDataLibrary
{
    class TownerMath
    {
        static public float calcAngle(Vector2 v, Vector2 vOrig)
        {
            float f = Vector2.Dot(v, vOrig);
            float fdis1 = v.Length();
            float fdis2 = vOrig.Length();
            double fcosa = f / (fdis1 * fdis2);
            float froatecur = (float)Math.Acos(fcosa);
            if (v.X > 0 && v.Y < 0)
                froatecur = 6.28f - froatecur;
            if (v.X > 0 && v.Y >= 0)
                froatecur = 6.28f - froatecur;
            return froatecur;
        }
          static public Rectangle CalcRect(float fsx, float fsy, Rectangle rt)
        {
            Rectangle rtDes = new Rectangle((int)(rt.Left * fsx), (int)(rt.Top * fsy),
                (int)((rt.Right - rt.Left) * fsx), (int)((rt.Bottom - rt.Top) * fsy));
            return rtDes;
        }
        static public Vector2 CalcPt(Vector2 v, float fsx, float fsy)
        {
            Vector2 vDes = new Vector2(v.X * fsx, v.Y *fsy);
            return vDes;
        }
    }
 }
